const app = getApp();
const publicFun = require('/utils/public.js');
import { getJianSuDetail } from '/utils/request'
Page({
  data: {
    auditStateList: [
      {id: 0, url: '/images/my/icon_state_yellow.png', text: '正在审核'},
      {id: 1, url: '/images/my/icon_state_green.png', text: '审核已通过'},
      {id: 2, url: '/images/my/icon_state_red.png', text: '审核未通过'}
    ],
    ruleMask: false,
  },
  onLoad(options) {
    this.setData({
      systemInfo: app.globalData.systemInfo
    })
    my.setNavigationBarColor({
      frontColor: '#000000',
      backgroundColor: '#ffffff',
    })
    this.getJianSuPos(options)
  },
  openRuleMask() {
    this.setData({
      ruleMask: true,
    });
  },
  closeMask() {
    this.setData({
      ruleMask: false,
    });
  },
  async getJianSuPos(data) {
    try{
      my.showLoading();
      let params = {
        menuid: app.globalData.menuid,
        id: data.id, //有值是获取某一条的详情， 没值是获取地址
        jiansuindustryid: data.jsid
      }
      const res = await getJianSuDetail(params);
      my.hideLoading();
      if(res.S == 1){
        res.JianYi = publicFun.Base64.decode(res.JianYi);
        res.StateContent = this.data.auditStateList[Number(res.State)];
        
        let content = publicFun.Base64.decode(res.NoPassReason);
        this.setData({
          jianSuList: res,
          NoPassReason: content
        })
      }else{

      }
    }catch(e) {
      my.hideLoading();
      publicFun.showToast('失败，请稍后再试')
    }
  },

  previewImage(e) { //查看大图
    let data = e.currentTarget.dataset;
    let list = data.list.split(",");
    let arr = [];
    for(let i=0;i<list.length;i++){
      arr.push(list[i].replace(/\/ico/g, ''));
    }
    my.previewImage({
      current: data.index,
      enablesavephoto: true,
      urls: arr
    });
  },
});